package com.oauth.google.server.shared;

import java.util.ArrayList;
import java.util.List;

import com.google.gdata.data.appsforyourdomain.generic.GenericEntry;
import com.oauth.google.client.beans.gmail.GoogleMail;

public class GMailUtils {

	public static List<GoogleMail> getMailList(List<GenericEntry> entries) {
		List<GoogleMail> mailList = new ArrayList<GoogleMail>();
		if (entries != null) {
			for (GenericEntry entry : entries) {
				mailList.add(convertToMail(entry));
			}
		}
		return mailList;
	}

	private static GoogleMail convertToMail(GenericEntry entry) {
		GoogleMail mail = new GoogleMail();
		mail.setSubject(entry.getTitle().getPlainText());
		mail.setSummary(entry.getSummary().getPlainText());
		// set author,link.
		return mail;
	}

}
